home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1996 April
/
EnigmA AMIGA RUN 06 (1996)(G.R. Edizioni)(IT)[!][issue 1996-04][Skylink CD V].iso
/
earcd
/
utilgfx
/
raylab.lha
/
RayLab
/
source
/
camera.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-01-04
|
1KB
|
48 lines
/*
name: camera.c
Camera-routines
---------------
These routines are used for handling the camera (positioning, scanning
rotation etc).
*/
#include "defs.h"
void CreateCamera(CAMERA *Camera, POINT *Loc, POINT *VP, VECTOR *Asp)
{
double length,scale,theta;
VECTOR D,R,U;
CopyPoint(&(Camera->Location),Loc); /* Declare camera location */
CopyPoint(&(Camera->ViewPoint),VP); /* Declare view-point */
D.x=(VP->x-Loc->x); /* Calculate direction-vector */
D.y=(VP->y-Loc->y);
D.z=(VP->z-Loc->z);
length=VectorLength(&D); /* Make direction-vector unit-sized */
scale=1/length; /* This is important for the calcu- */
ScaleVector(&D, scale, &D); /* lations of the up- and right- */
/* vectors! */
CopyVector(&(Camera->Direction),&D); /* Declare camera direction */
theta=asin(D.z); /* Calculate right-vector */
R.x=D.y/cos(theta); /* "/cos(theta)" => |R| = 1 */
R.y=-(D.x/cos(theta));
R.z=(double) 0;
CopyVector(&(Camera->Right),&R); /* Declare camera right-vector */
CrossProduct(&U,&R,&D); /* U = R x D */
CopyVector(&(Camera->Up),&U); /* Declare camera up-vector */
CopyVector(&(Camera->Aspect),Asp); /* Declare camera aspect */
}